// pages/tool/card/index/detail/detail.js
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        threetype:['商品信息','印刷订单','电子券分发订单'],
        status: {1: '未确认',2: '印刷中',3: '已完成',4:'未支付'},
        distribute: {1: '分发中',2: '已领取',3: '已撤销'},
        nowIndex:0,
        id:0,
        cardinfo:[]
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
          this.setData({
              id:options.id
          },()=>{
              this.carddetail(options.id)
          });
    },


    carddetail: function (id) {
        app.func.getPromise('/cardtype/carddetail/' + id)
            .then(([code,res])=>{
                  this.setData({ cardinfo:res.data});
            })
    },

    onTab:function(e){
        let index = e.currentTarget.dataset.index;
        this.setData({ nowIndex:index});
    },


    viewsku:function(e){
        var id = e.currentTarget.dataset.id;
        wx.navigateTo({
            url: '/pages/index/productdetail/productdetail?id=' + id
        })
    },

    preview:function(e) {
        var id = this.data.id;
        wx.navigateTo({
            url: '/tools/pages/tool/card/index/preview/preview?id=' + id
        })
    },

    printdetail:function (e) {
        let id = e.currentTarget.dataset.id;
        wx.navigateTo({
            url:'/pages/about/card/print/detail/detail?id=' + id
        })
    },

    distributeDetail:function (e) {
        let id = this.data.id;
        let num = e.currentTarget.dataset.num;
        let id1 = e.currentTarget.dataset.id1;
        wx.navigateTo({
            url:`/pages/about/card/distribute/detail/detail?id=${id}&num=${num}&id1=${id1}`
        })
    }

})
